const express=require("express");
const bodyParser=require("body-parser")
let app=express();

app.all('*', function(req, res, next) {
    res.header("Access-Control-Allow-Origin", "*");
    res.header("Access-Control-Allow-Headers", "Content-Type,Content-Length, Authorization, Accept,X-Requested-With");
    res.header("Access-Control-Allow-Methods","PUT,POST,GET,DELETE,OPTIONS");
    res.header("X-Powered-By",' 3.2.1')
    if(req.method=="OPTIONS") res.sendStatus(200);/*让options请求快速返回*/
    else  next();
});

app.use(bodyParser.json())
app.use(bodyParser.urlencoded({extended:true}))

let {getRecommendData}=require("./recommend/getRecommendData")
let {singerData}=require("./singer/getSinger")
let {singerDetail}=require("./singerDetail/getsingerDetail")
let {getRecommendDetailData}=require("./recommendDetail/setRecommendDetail")
let {getSongDetailData}=require("./songDetail/getSongDetail")
let {getRankData} = require("./rank/getRankData");
let {getRankDetail} = require("./rankDetail/getRankDetail");
let {getHotKey} =require("./hotKey/getHotKey")
let {getSearchResult} = require("./search/getSearchData");
app.get("/api/getRecommendData",getRecommendData)
app.post("/api/getRecommendDetailData/:id",getRecommendDetailData)
app.get("/api/singerData",singerData)
app.post("/api/singerDetail",singerDetail)
app.post("/api/getSongDetailData",getSongDetailData)
app.get("/api/getRankData",getRankData);
app.get("/api/getRankDetailData/:id",getRankDetail);
app.get("/api/getHotKey",getHotKey);
app.get("/api/getSearchResult/:id",getSearchResult);

app.listen(1111)